package com.atguigu.juc;

interface Foo{
    public void sayHello();
}
@FunctionalInterface//显式
interface Test{
        public int add(int x, int y);

        default int sub(int x,int y){
            return x-y;
        }
         public static int div(int x,int y){
            return x/y;
        }
}
/**
 * @author ：MJS
 * @date ：Created in 2021/4/23  19:26
 * @description：Lambda的练习
 * lambda  前提 ：函数式接口（内部只有一个方法）--->lambda Express
 * 拷贝小括号，写死右箭头，落地大括号
 * 定义。隐式和显式
 */
public class LambdaExpressDemo {

    public static void main(String[] args) {
       /* Foo foo=new Foo() {
            @Override
            public void sayHello() {
                System.out.println("hello java");
            }
        };
        foo.sayHello();;*/
       Foo foo=()->{System.out.println("hello java");};
       foo.sayHello();

       Test test=(x, y)->{return x+y;};
        System.out.println(test.add(2, 6));
        System.out.println(test.sub(5, 2));
        System.out.println(Test.div(10, 2));

    }
}
